﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Silverlight.Testing;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SilverTile.Xaml;

namespace SilverTileTests
{
    [TestClass]
    public class XamlSpriteTileTests
    {
        [TestMethod]
        public void SpriteTile_Should_Have_X_Y_Blocking_And_Frame_Properties()
        {

            var frame = new SpriteFrame();
            var spriteTile = new SpriteTile
            {
                X = 1,
                Y = 2,
                Blocking = true,
                Frame = frame
            };

            Assert.AreEqual(1, spriteTile.X, "X was not set correctly");
            Assert.AreEqual(2, spriteTile.Y, "Y was not set correctly");
            Assert.IsTrue(spriteTile.Blocking, "Blocking was not set correctly");
            Assert.AreSame(frame, spriteTile.Frame, "Frame was not set correctly");

            Assert.AreEqual(spriteTile.X, spriteTile.GetValue(SpriteTile.XProperty), "X and XProperty does not return the same value");
            Assert.AreEqual(spriteTile.Y, spriteTile.GetValue(SpriteTile.YProperty), "Y and YProperty does not return the same value");
            //Assert.AreEqual(spriteTile.Blocking, spriteTile.GetValue(SpriteTile.BlockingProperty), "Blocking and BlockingProperty does not return the same value");
            Assert.AreEqual(spriteTile.Frame, spriteTile.GetValue(SpriteTile.FrameProperty), "Frame and FrameProperty does not return the same value");

        }

        [TestMethod]
        public void SpriteTile_Should_Have_Transition_Property()
        {

            var transition = new AreaTransition() { TargetRow = 1, TargetColumn = 1, GameAreaName = "Area1" };
            var spriteTile = new SpriteTile { Transition = transition };

            Assert.AreSame(transition, spriteTile.Transition, "Transition was not set correctly");
            Assert.AreSame(spriteTile.Transition, spriteTile.GetValue(SpriteTile.TransitionProperty), "Transition and TransitionProperty does not return the same value");

        }

        [TestMethod]
        public void SpriteTile_Should_Have_SpawnPoint_Property()
        {

            var spawnPoint = new SpawnPoint();
            var spriteTile = new SpriteTile { SpawnPoint = spawnPoint };

            Assert.AreSame(spawnPoint, spriteTile.SpawnPoint, "SpawnPoint was not set correctly");
            Assert.AreSame(spriteTile.SpawnPoint, spriteTile.GetValue(SpriteTile.SpawnPointProperty), "SpawnPoint and SpawnPointProperty does not return the same value");

        }

        [TestMethod]
        public void SpriteTile_Should_Use_Blocking_Property_From_Its_Frame_If_No_Value_Is_Set()
        {


            var frame = new SpriteFrame
            {
                Blocking = true
            };
         
            var spriteTile1 = new SpriteTile
            {
                Frame = frame
            };

            var spriteTile2 = new SpriteTile
            {
                Blocking = false,
                Frame = frame
            };

            Assert.IsTrue(spriteTile1.Blocking, "Blocking was not inehrited from frame");
            Assert.IsFalse(spriteTile2.Blocking, "Blocking was not overriden for tile");
            

        }

    }
}